Conversation
fixes 3 failing tests related to OnPlatform
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a code generation issue in the XAML source generator related to double casting when adding items to collections. The fix addresses 3 failing tests that were experiencing issues with OnPlatform functionality by properly handling intermediate implicit conversions during collection item addition.
- Removes conditional compilation directives from test methods that were limiting test parameter values
- Adds logic to detect and handle double implicit conversions in the source generator's Add method
- Ensures proper casting chain when adding items to collections that require intermediate type conversions
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Controls/tests/Xaml.UnitTests/Issues/Maui4509.xaml.cs | Removes conditional compilation blocks from OnPlatform test methods |
| src/Controls/tests/Xaml.UnitTests/Issues/Maui24900.xaml.cs | Removes conditional compilation blocks from OnPlatform test method |
| src/Controls/src/SourceGen/Visitors/SetPropertiesVisitor.cs | Adds double implicit conversion detection and intermediate casting logic |
| //look for intermediate implicit casts | ||
| string cast = string.Empty; | ||
| if (HasDoubleImplicitConversion(context.Variables[valueNode].Type, itemType, context, out var conv)) | ||
| cast = "(" + conv!.ReturnType.ToFQDisplayString() + ")"; |
There was a problem hiding this comment.
The method HasDoubleImplicitConversion is called but not defined in this file or visible in the diff. This will cause a compilation error unless this method exists elsewhere in the class or is imported.
There was a problem hiding this comment.
get out, Copilot, you're drunk
| //look for intermediate implicit casts | ||
| string cast = string.Empty; | ||
| if (HasDoubleImplicitConversion(context.Variables[valueNode].Type, itemType, context, out var conv)) | ||
| cast = "(" + conv!.ReturnType.ToFQDisplayString() + ")"; |
There was a problem hiding this comment.
| cast = "(" + conv!.ReturnType.ToFQDisplayString() + ")"; | |
| cast = $"({conv!.ReturnType.ToFQDisplayString()})"; |
Description of Change
fixes 3 failing tests related to OnPlatform